package org.queryexecutor.swing.panels;

import java.awt.GridBagLayout;
import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.GridBagConstraints;
import javax.swing.JTextField;
import java.awt.Insets;
import javax.swing.JButton;
import javax.swing.JPasswordField;
import javax.swing.border.EmptyBorder;
import javax.swing.SwingConstants;

public class LocalFilePanel extends JPanel
{
	
	private static final long	serialVersionUID	= 1L;
	private JTextField txtFile;
	private JTextField txtUsername;
	private JPasswordField txtPassword;
	
	public JTextField getTxtFile()
	{
		return this.txtFile;
	}

	public JTextField getTxtUsername()
	{
		return this.txtUsername;
	}

	public JPasswordField getTxtPassword()
	{
		return this.txtPassword;
	}

	/**
	 * This is the default constructor
	 */
	public LocalFilePanel()
	{
		super();
		setBorder(new EmptyBorder(5, 5, 5, 5));
		initialize();
	}
	
	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize()
	{
		this.setSize(300, 79);
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[]{52, 191, 47, 0};
		gridBagLayout.rowHeights = new int[]{23, 20, 20, 0};
		gridBagLayout.columnWeights = new double[]{0.0, 1.0, 0.0, Double.MIN_VALUE};
		gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
		setLayout(gridBagLayout);
		
		JLabel lblFile = new JLabel("File:");
		lblFile.setHorizontalAlignment(SwingConstants.LEFT);
		GridBagConstraints gbc_lblFile = new GridBagConstraints();
		gbc_lblFile.fill = GridBagConstraints.HORIZONTAL;
		gbc_lblFile.insets = new Insets(0, 0, 5, 5);
		gbc_lblFile.gridx = 0;
		gbc_lblFile.gridy = 0;
		add(lblFile, gbc_lblFile);
		
		this.txtFile = new JTextField();
		this.txtFile.setColumns(10);
		GridBagConstraints gbc_txtFile = new GridBagConstraints();
		gbc_txtFile.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtFile.insets = new Insets(0, 0, 5, 5);
		gbc_txtFile.gridx = 1;
		gbc_txtFile.gridy = 0;
		add(this.txtFile, gbc_txtFile);
		
		JButton btnOpen = new JButton("...");
		GridBagConstraints gbc_btnOpen = new GridBagConstraints();
		gbc_btnOpen.insets = new Insets(0, 0, 5, 0);
		gbc_btnOpen.gridx = 2;
		gbc_btnOpen.gridy = 0;
		add(btnOpen, gbc_btnOpen);
		
		JLabel lblUsername = new JLabel("Username:");
		GridBagConstraints gbc_lblUsername = new GridBagConstraints();
		gbc_lblUsername.fill = GridBagConstraints.HORIZONTAL;
		gbc_lblUsername.insets = new Insets(0, 0, 5, 5);
		gbc_lblUsername.gridx = 0;
		gbc_lblUsername.gridy = 1;
		add(lblUsername, gbc_lblUsername);
		
		this.txtUsername = new JTextField();
		this.txtUsername.setColumns(10);
		GridBagConstraints gbc_txtUsername = new GridBagConstraints();
		gbc_txtUsername.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtUsername.insets = new Insets(0, 0, 5, 0);
		gbc_txtUsername.gridwidth = 2;
		gbc_txtUsername.gridx = 1;
		gbc_txtUsername.gridy = 1;
		add(this.txtUsername, gbc_txtUsername);
		
		JLabel lblPassword = new JLabel("Password:");
		GridBagConstraints gbc_lblPassword = new GridBagConstraints();
		gbc_lblPassword.fill = GridBagConstraints.HORIZONTAL;
		gbc_lblPassword.insets = new Insets(0, 0, 0, 5);
		gbc_lblPassword.gridx = 0;
		gbc_lblPassword.gridy = 2;
		add(lblPassword, gbc_lblPassword);
		
		this.txtPassword = new JPasswordField();
		GridBagConstraints gbc_txtPassword = new GridBagConstraints();
		gbc_txtPassword.fill = GridBagConstraints.HORIZONTAL;
		gbc_txtPassword.gridwidth = 2;
		gbc_txtPassword.gridx = 1;
		gbc_txtPassword.gridy = 2;
		add(this.txtPassword, gbc_txtPassword);
	}
	
}
